package cn.tedu;

import java.sql.*;

public class Demo03 {
    public static void main(String[] args) throws SQLException {
        Connection connection = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/empdb?characterEncoding=utf8&serverTimezone=Asia/Shanghai",
                "root","");
        Statement statement = connection.createStatement();
//        statement.executeUpdate("insert into emp(name) values ('汤姆')");
//        statement.executeUpdate("update emp set name='杰瑞' where name='汤姆'");
//     statement.executeUpdate("delete from emp where name='杰瑞'");
        ResultSet rs = statement.executeQuery(" select name ,sal from emp");
        while (rs.next()){
//            String name = rs.getString("name");
//            double sal = rs.getDouble("sal");
            String name = rs.getString(1);
            double sal = rs.getDouble(2);
            System.out.println(name+":"+sal);
        }
        connection.close();


    }
}
